<script type="text/javascript">
  function saveComment() {
    document.getElementById('commentsForm').submit()
    return false
  }
  function removeComment() {
    document.getElementById('commentsText').value = ''
    document.getElementById('commentsForm').submit()
    return false
  }
</script>

<h1>
<%=@vehicle.title%>
[<a target="_blank" href="<%=@vehicle.url%>">Goto</a>]
</h1>


<h3><b>Submitted at:</b> <%=@vehicle.submit_date%> - <%=@vehicle.submit_time%></h3>

<p><b>Brand:</b> <%=@vehicle.brand.name%> &nbsp;&nbsp;&nbsp;
<b>Model:</b> <%=@vehicle.model%> &nbsp;&nbsp;&nbsp;
<b>Mileage:</b> <%=@vehicle.mileage%></p>

<p><b>Price:</b> <%=@vehicle.price%> &nbsp;&nbsp;&nbsp;
<b>Contact number:</b> <%=@vehicle.contact_number%> &nbsp;&nbsp;&nbsp;
<b>Vehicle type:</b> <%=@vehicle.vtype%></p>

<p>
  <b>Description:</b> <br/>
  <%=@vehicle.description.gsub(/\n/, "<br/>") if @vehicle.description %> <%=@vehicle.others%>
</p>
<p>
  <b>Comments:</b>
  <a href="#" onclick="return saveComment()">Save</a>
  -
  <a href="#" onclick="return removeComment()">Remove</a>
  <br/>
  <form id="commentsForm" method="GET" action="/vehicles/comment/<%=@vehicle.id%>">
  <textarea id="commentsText" name="text" rows=2 cols=120><%=@vehicle.comments%></textarea>
  </form>
</p>

<h3>
<%if @vehicle.favorite%>
  <%= link_to 'Remove from favorites', :action => 'favor', :id => @vehicle.id %>
<%else%>
  <%= link_to 'Add to favorites', :action => 'favor', :id => @vehicle.id %>
<%end%>

</h3>

<%= link_to 'Back', :action => 'index' %>

